home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / graphics / motionrd.zip / README.ASM < prev    next >
Assembly Source File  |  1994-12-04  |  12KB  |  319 lines

  1. ; Smooth vertical scroller by Patch - hamell@cs.pdx.edu
  2. ; Made for the intro Motion by Avalanche
  3. ; Done sometime in December 1993
  4. ;
  5. ; If you use this code in any manner, please inform me.
  6. ;
  7. ; If you want to be cool, modify this so the number of lines can be unlimited.
  8. ; If you do so, please email me the new source code.
  9.  
  10. .model small
  11. .stack 1024
  12. .386
  13.  
  14. .data
  15. linecount       db      0
  16. screen_offs     dw      160
  17. include         status.inc
  18. include         motion-a.inc
  19.  
  20. .code
  21. TOPSCREENOFFS   EQU     160
  22. LINECOMPAREVAL  EQU     367
  23. VIEWLINES       EQU     23
  24. PIXELSTEP       EQU     2
  25. NUMSTEPS        EQU     14/PIXELSTEP
  26. include         key.inc
  27.  
  28. WaitVRetrace    MACRO
  29.                 LOCAL   VRetrace,NoVRetrace
  30.                 mov     dx,03dah
  31. VRetrace:       in      al,dx
  32.                 test    al,00001000b
  33.                 jnz     VRetrace
  34. NoVRetrace:     in      al,dx
  35.                 test    al,00001000b
  36.                 jz      NoVRetrace
  37.                 ENDM
  38.  
  39. WaitVActive     MACRO
  40.                 LOCAL   VActive
  41.                 mov     dx,03dah
  42. VActive:        in      al,dx
  43.                 test    al,00001000b
  44.                 jnz     VActive
  45.                 ENDM
  46.                 
  47. WaitVInactive   MACRO
  48.                 LOCAL   VInactive
  49.                 mov     dx,03dah
  50. VInactive:      in      al,dx
  51.                 test    al,00001000b
  52.                 jz      VInactive 
  53.                 ENDM
  54.  
  55. WaitHRetrace    MACRO
  56.                 LOCAL   HRetrace,NoHRetrace
  57.                 mov     dx,03dah
  58. HRetrace:       in      al,dx
  59.                 test    al,00000001b
  60.                 jnz     HRetrace
  61. NoHRetrace:     in      al,dx
  62.                 test    al,00000001b
  63.                 jz      NoHRetrace
  64.                 ENDM
  65.  
  66. WaitHActive     MACRO
  67.                 LOCAL   HActive
  68.                 mov     dx,03dah
  69. HActive:        in      al,dx
  70.                 test    al,00000001b
  71.                 jnz     HActive
  72.                 ENDM
  73.                 
  74. WaitHInactive   MACRO
  75.                 LOCAL   HInactive
  76.                 mov     dx,03dah
  77. HInactive:      in      al,dx
  78.                 test    al,00000001b
  79.                 jz      HInactive
  80.                 ENDM
  81.  
  82. Set_Start_Addr  MACRO
  83.                 mov     bx,[screen_offs]        ; set starting address
  84.                 mov     dx,03d4h
  85.                 mov     al,0ch
  86.                 mov     ah,bh
  87.                 out     dx,ax
  88.                 inc     al
  89.                 mov     ah,bl
  90.                 out     dx,ax
  91.                 ENDM
  92.  
  93. start:          mov     ax,@data
  94.                 mov     ds,ax
  95.  
  96.                 call    _Set_New_Int9
  97.                 
  98.                 mov     ax,0003h
  99.                 int     10h
  100.                 mov     ax,0100h                ; hide the cursor
  101.                 mov     cx,0800h
  102.                 int     10h
  103.  
  104.                 WaitVRetrace
  105.                 push    LINECOMPAREVAL
  106.                 call    _Set_Line_Compare
  107.                 add     sp,2
  108.  
  109.                 Set_Start_Addr
  110.                 WaitVRetrace
  111.  
  112.                 cld
  113.                 mov     ax,0b800h               ; dump status bar to screen
  114.                 mov     es,ax
  115.                 xor     di,di
  116.                 mov     si,offset STATUSBAR
  117.                 mov     cx,STATUSBAR_LEN
  118.                 rep     movsw
  119.  
  120.                 mov     di,[screen_offs]        ; dump ansi to screen
  121.                 shl     di,1                    ; *2, each offset is 2 bytes
  122.                 mov     si,offset ANSI_SCREEN
  123. ;                add     si,160
  124.                 mov     cx,ANSI_DEPTH*80
  125.                 rep     movsw
  126.                 
  127. get_key: 
  128. ;                cmp     cs:[_keynumpress],0
  129. ;                je      get_key
  130.                 
  131.                 cmp     cs:_keys[kUARROW],1     ; cursor up?
  132.                 je      key_up
  133.                 cmp     cs:_keys[kKEYPAD8],1    ; cursur up?
  134.                 je      key_up
  135.                 cmp     cs:_keys[kDARROW],1     ; cursor down?
  136.                 je      key_down
  137.                 cmp     cs:_keys[kKEYPAD2],1    ; cursor down?
  138.                 je      key_down
  139.                 cmp     cs:_keys[kHOME],1       ; home?
  140.                 je      key_home
  141.                 cmp     cs:_keys[kEND],1        ; end?
  142.                 je      key_end
  143.                 cmp     cs:_keys[kPGUP],1       ; pgup?
  144.                 je      key_pgup
  145.                 cmp     cs:_keys[kPGDN],1       ; pgdn?
  146.                 je      key_pgdn
  147.                 cmp     cs:_keys[kESC],1        ; esc?
  148.                 je      exit
  149.                 jmp     get_key
  150.                 
  151. key_up:         cmp     [linecount],0           ; at top?
  152.                 je      get_key                 ; if so, jump
  153.                 dec     [linecount]             
  154.                 sub     [screen_offs],80        ; one line up
  155.  
  156.                 WaitVRetrace
  157.                 Set_Start_Addr
  158.                 
  159.                 mov     bx,1008h                ; start at char line 14
  160.                 mov     cx,NUMSTEPS
  161. pan_up:         WaitVInactive
  162.                 WaitHActive
  163.                 sub     bh,PIXELSTEP            ; next line of char
  164.                 mov     dx,03d4h
  165.                 mov     ax,bx
  166.                 out     dx,ax
  167.                 dec     cx
  168.                 jnz     pan_up
  169.  
  170.                 WaitVInactive
  171.                 WaitHActive
  172.                 mov     dx,03d4h
  173.                 mov     ax,0008h                ; set char line to 0
  174.                 out     dx,ax
  175.                 
  176.                 jmp     get_key
  177.  
  178. key_down:       cmp     [linecount],ANSI_DEPTH-VIEWLINES
  179.                 je      get_key
  180.                 inc     [linecount]
  181.                 add     [screen_offs],80
  182.                 
  183.                 mov     bx,0008h                ; start at char line 0
  184.                 mov     cx,NUMSTEPS
  185. pan_down:       WaitVInactive
  186.                 WaitHActive
  187.                 add     bh,PIXELSTEP            ; next char line
  188.                 mov     dx,03d4h
  189.                 mov     ax,bx
  190.                 out     dx,ax
  191.                 dec     cx
  192.                 jnz     pan_down
  193.  
  194.                 WaitVRetrace
  195.                 Set_Start_Addr
  196.                 
  197.                 WaitVInactive
  198.                 WaitHActive
  199.                 mov     dx,03d4h
  200.                 mov     ax,0008h                ; set char line to 0
  201.                 out     dx,ax
  202.  
  203.                 jmp     get_key
  204.  
  205. key_home:       cmp     [linecount],0
  206.                 je      get_key
  207.                 mov     [linecount],0
  208.                 mov     [screen_offs],TOPSCREENOFFS
  209.  
  210.                 WaitVRetrace
  211.                 Set_Start_Addr
  212.                 
  213.                 jmp     get_key
  214.                 
  215. key_end:        cmp     [linecount],ANSI_DEPTH-VIEWLINES
  216.                 je      get_key
  217.                 mov     [linecount],ANSI_DEPTH-VIEWLINES
  218.                 mov     [screen_offs],(ANSI_DEPTH-VIEWLINES)*80
  219.                 add     [screen_offs],TOPSCREENOFFS
  220.  
  221.                 WaitVRetrace
  222.                 Set_Start_Addr
  223.                 
  224.                 jmp     get_key
  225.                 
  226. key_pgup:       cmp     [linecount],0           ; at top line?
  227.                 je      get_key
  228.                 cmp     [linecount],24          ; full screen left to view?
  229.                 jbe     key_home                ; if not, jump
  230.                 
  231.                 sub     [linecount],VIEWLINES
  232.                 sub     [screen_offs],80*VIEWLINES
  233.  
  234.                 WaitVActive
  235.                 Set_Start_Addr
  236.  
  237.                 mov     cx,8
  238. pan_pgup:       WaitVRetrace
  239.                 dec     cx
  240.                 jnz     pan_pgup
  241.                 
  242.                 jmp     get_key
  243.                 
  244. key_pgdn:       cmp     [linecount],ANSI_DEPTH-VIEWLINES ; at bottom line?
  245.                 je      get_key
  246.                 cmp     [linecount],ANSI_DEPTH+1-VIEWLINES*2
  247.                                                         ; full screen to view?
  248.                 jae     key_end                         ; if not, jump
  249.                 
  250.                 add     [linecount],VIEWLINES
  251.                 add     [screen_offs],80*VIEWLINES
  252.  
  253.                 WaitVRetrace
  254.                 Set_Start_Addr
  255.                 
  256.                 mov     cx,8
  257. pan_pgdn:       WaitVRetrace
  258.                 dec     cx
  259.                 jnz     pan_pgdn
  260.                 
  261.                 jmp     get_key
  262.                 
  263. exit:           call    _Set_Old_Int9
  264.                 mov     ax,0003h                ; text mode 3
  265.                 int     10h
  266.                 mov     ax,4c00h                ; exit
  267.                 int     21h
  268.  
  269.  
  270. ;******************************************************************************
  271. ;* PROC    : void Set_Line_Compare(word rasterline);
  272. ;* Purpose : Sets the line compare
  273. ;*           The area above the line compare is the segment and offset where
  274. ;*                the start address is set to.
  275. ;*           The area below the line compare is at A000:0000.
  276. ;* Entrance: rasterline - the raster line to set for line compare
  277. ;*                        for every pixel line, there are 2 raster lines
  278. ;*                        so pixel line 100 is raster line 200
  279. ;* Exit    : nothing
  280. ;******************************************************************************
  281. _Set_Line_Compare       PROC    NEAR
  282.                         push    bp
  283.                         mov     bp,sp
  284.  
  285.                         mov     bx,[bp + 4]             ; BX = line value
  286.                         mov     dx,03d4h                ; CRTC reg
  287.  
  288.                         mov     al,09h                  ; 09h = max scan line index
  289.                         out     dx,al                   ; 10th bit of line compare
  290.                         inc     dl                      ;   goes in bit 6 of the index
  291.                         in      al,dx                   ; read in previous contents
  292.                         mov     ah,bh                   ; get bit 10 of line compare
  293.                         or      ah,11111101b            ; make other bits 1 as a mask
  294.                         ror     ah,03h                  ; move to bit 6
  295.                         and     al,ah                   ; AND them together
  296.                         out     dx,al
  297.  
  298.                         dec     dl                      ; 03d4h
  299.                         mov     al,07h                  ; 07h = overflow index
  300.                         out     dx,al                   ; 9th bit of line compare
  301.                         inc     dl                      ;   goes in bit 4 of the index
  302.                         in      al,dx                   ; read in previous contents
  303.                         mov     ah,bh                   ; get bit 9 of line compare
  304.                         or      ah,11111110b            ; make other bits 1 as a mask
  305.                         rol     ah,04h                  ; move to bit 4
  306.                         and     al,ah                   ; AND them together
  307.                         out     dx,al
  308.  
  309.                         dec     dl                      ; 03d4h
  310.                         mov     al,18h                  ; 18h = line compare index
  311.                         mov     ah,bl                   ; AH = lower 8 bits
  312.                         out     dx,ax
  313.  
  314.                         pop     bp
  315.                         ret
  316. _Set_Line_Compare       ENDP
  317.  
  318.                 END     start
  319.